<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		
		<title>同创未来|官网</title>
		 
	</head>
	<style type="text/css">
		.form-group{margin-left: 44%;}
	</style>
<script type="text/javascript" src="../../js/jquery-1.7.2.js"></script>
	<body>
	
<h1 style="text-align: center;padding: 15px;font-size: 26px;">同创未来有限公司用户注册</h1>
<div class="con-wrap">
  <div class="con ct " >
   <h4 class="regh" style="border-bottom: 1px solid red;margin: 30px 250px 50px 250px;padding-bottom: 50px;text-align: center;">以下内容我们承诺信息安全，不会透露给第三方，请认真填写，<span class="red" style="color: red;">*</span>为必填内容</h4>
	<form action="" class="regbox ct" style="width: 100%;">
     <div class="login_form">
          <form action="" id="regist_form" method="post">
            <div class="form-group" style="margin-bottom:30px;">
              <span style="color:red;">* </span><label for="name" class="t">用&nbsp; 户 &nbsp;&nbsp;名：</label> <input id="name" value="" name="name" type="text"
                onblur="name();" class="password form-control x319 in"><span id="name" class="err"></span>
            </div>
            <div class="form-group" style="margin-bottom:30px;">
              <span style="color:red;">* </span><label for="j_username" class="t">邮&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;箱：</label> <input id="username" value="" name="username" type="text"
                onblur="checkUsername();" class="password form-control x319 in"><span id="usernamemsg" class="err"></span>
            </div>
            <div class="form-group" style="margin-bottom:30px;">
               <span style="color:red;">* </span><label for="j_password" class="t">密&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;码：</label> <input id="password" value="" name="password" type="password"
                onblur="checkPassword();" class="password form-control x319 in"><span id="passwordmsg" class="err"></span>

            </div>
            <div class="form-group" style="margin-bottom:30px;">
               <span style="color:red;">* </span><label for="j_password" class="t">确&nbsp;认&nbsp;密&nbsp;码：</label> <input id="repassword" value="" name="repassword" type="password"
                onblur="checkRepassword();" class="password form-control x319 in"> <span id="repasswordmsg"
                class="err"></span>

            </div>
            <div class="form-group" style="margin-bottom:30px;">
               <span style="color:red;">* </span><label for="j_password" class="t">姓&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;名：</label> <input id="nick" value="" name="nick" type="text"
                onblur="checkName();" class="password form-control x319 in"> <span id="nameerrormsg" class="err"></span>

            </div>
            <div class="form-group" style="margin-bottom:30px;">
               <span style="color:red;">* </span><label for="j_password" class="t">身&nbsp;&nbsp;份&nbsp;&nbsp;证：</label> <input id="idcard" value="" name="idcard" type="text"
                onblur="checkIdcard();" class="form-control x319 in" maxlength="18"> <span id="idcardmsg" class="err"></span>

            </div>

            <div class="form-group" style="margin-bottom:30px;">
               <span style="color:red;">* </span><label for="j_password" class="t">手&nbsp;&nbsp;机&nbsp;&nbsp;号：</label> <input id="mobile" value="" name="mobile" type="text"
                onblur="checkMobile();" class="form-control x319 in" maxlength="11"> <span id="mobilemsg" class="err"></span>

            </div>
            
            <input style='margin-left:46%; margin-right:20px;' id="cbx" type="checkbox" onclick="checkYX();"><a
              style=' margin-right:20px;text-decoration: none;' href='xieyi.html' target="_black">&nbsp;我已阅读用户协议</a>
            
            <div class="form-group space" style="margin:30px;margin:0 auto;text-align: center;">
              <label class="t"></label><!--disabled="disabled" -->
              <button type="button" id="submit_btn" name="submit" value="submit" onclick="dosubmit();"
                class="btn btn-primary btn-lg" style="float:left;position:absolute ;left: 45%;margin-top: 20px;">&nbsp;注&nbsp;册&nbsp;</button>
              <input type="reset" value="&nbsp;重&nbsp;置&nbsp;" class="btn btn-default btn-lg" style="float:left;position:absolute ;left: 52%;margin-top: 20px;">
            </div>
            </div>
          </form>
          </form>
          </div>
          </div>
    <script>

  $(function() {

        $('.dr').click(function() {

      $('.dl').show();

    });

            $('.gb').click(function() {

      $('.dl').hide();

     

     

    }); 

  })

</script>
<script src="js/jquery-1.7.2.js"></script>

<script type="text/javascript">
  
  $(function(){
    var v = $("input[type='checkbox']").is(':checked');
    if(v){
      $('#submit_btn').removeAttr('disabled');    
    }
  });
  function checkYX(){
    var v = $("input[type='checkbox']").is(':checked');
    if(v){
      $('#submit_btn').removeAttr('disabled');    
    }else{
      $('#submit_btn').attr('disabled','disabled');
    }
  }
    $('#name').html('');
  $('#usernamemsg').html('');
  $('#passwordmsg').html('');
  $('#repasswordmsg').html('');
  $('#nameerrormsg').html('');
  $('#mobilemsg').html('');
  var errormsg="";
  function name(){
    var name=$('#name').val();
    if(name===0){
       errormsg="请输入用户名";
    }else{
      $('#name').html('');
    } 
  }
  function checkUsername(){
    var vusername = $('#username').val();
    var reg =  /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
    if(!reg.test(vusername)){
      errormsg="请输入正确的邮箱";
      $('#usernamemsg').html(errormsg);
    }else{
      $('#usernamemsg').html('');
    } 
  }

  function checkPassword(){
    var value = $('#password').val();
    var reg = /^[a-zA-Z0-9]{1,12}$/;
    if(!reg.test(value)){
      errormsg="请输入正确的密码";
      $('#passwordmsg').html(errormsg); 
    }else{
      $('#passwordmsg').html(''); 
    } 
  }
  
  function checkRepassword(){
    var value = $('#password').val();
    var value2 = $('#repassword').val();
    
    if(value==value2){
      $('#repasswordmsg').html('');
    }else{
      errormsg="两次密码不一致";
      $('#repasswordmsg').html(errormsg); 
    } 
  }
  
  function checkName(){
    var value = $('#nick').val();
    var reg =   /^[\u4e00-\u9fa5]{2,5}$/;
    if(!reg.test(value)){
      errormsg="请输入正确的姓名";
      $('#nameerrormsg').html(errormsg);
    }else{
      $('#nameerrormsg').html('');
    } 
  }

  function checkIdcard(){
    var value = $('#idcard').val();
    var reg =/^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/;
    if(!reg.test(value)){
      errormsg="请输入正确的身份证";
      $('#idcardmsg').html(errormsg); 
    }else{
      $('#idcardmsg').html('');
        var vnick = $('#nick').val();
        $.ajax({
        cache: false,
        type: "POST",
        url:'http://27.50.136.66:9010/tyxbweb/CheckIdcard',
        data:{
          idcard:value,
          nick:vnick
        },// 你的formid
        async: true,
        dataType :"json",
        success: function(data) {
          if(data.success){
            errormsg="";
            $('#idcardmsg').html(errormsg); 
            //window.location.href="http://localhost:80/index.html";
          }else{
            alert("身份证不匹配");
            errormsg="身份证信息不匹配";
            $('#idcardmsg').html(errormsg); 
          }
        }
      });
      
    } 
  }
  
  function checkMobile(){
    var value = $('#mobile').val();
    var reg =/^1[34578]\d{9}$/;
    if(!reg.test(value)){
      errormsg="请输入正确的手机号";
      $('#mobilemsg').html(errormsg); 
    }else{
      $('#mobilemsg').html('');
    } 
  }

  function dosubmit(){
     checkUsername();checkPassword();checkRepassword();
   checkName();checkMobile();
    if(errormsg!=''){
      alert("校验未通过"+errormsg);
      return false;
    }else{
      $.ajax({
        cache: true,
        type: "POST",
        url:'http://27.50.136.66:9010/tyxbweb/UserServlet?command=regist',
        data:$('#regist_form').serialize(),// 你的formid
        async: false,
        dataType :"json",
        success: function(data) {
  
            window.location.href="../index.html";
          //var obj = jQuery.parseJSON(data);
          //console.info(obj);
          if(data.success){
            
            window.location.href="../inedx.html";
          }else{
            alert("注册失败请刷新后再试");
          }
        }
      });
    }
  }
 </script>
		     
	</body>
</html>